package com.weijianhuawen.wjblog.admin.controller;

import com.weijianhuawen.wjblog.admin.service.AdminDashboardService;
import com.weijianhuawen.wjblog.common.aspect.ApiOperationLog;
import com.weijianhuawen.wjblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2024-11-01 14:54
 */

@RestController
@RequestMapping("/admin/dashboard")
@Api(tags = "仪表盘模块")
public class AdminDashboardController {

    @Autowired
    private AdminDashboardService adminDashboardService;

    @GetMapping("/statistics")
    @ApiOperation(value = "获取基本统计数据")
    @ApiOperationLog(description = "统计文章 分类 标签 pv量等基本量的数据")
    public Response findDashboardStatistics() {
        return adminDashboardService.findDashboardStatistics();
    }

    @GetMapping("/publishArticle/statistics")
    @ApiOperation(value = "统计近一年内文章发布量")
    @ApiOperationLog(description = "统计近一年文章发布数据量")
    public Response findDashboardPublishArticleStatistics() {
        return adminDashboardService.findDashboardPublishArticleStatistics();
    }

    @GetMapping("/pv/statistics")
    @ApiOperation(value = "获取最近一周日pv")
    @ApiOperationLog(description = "获取最近一周的日pv量数据")
    public Response findDashboardPvStatisticsForLastWeek() {
        return adminDashboardService.findDashboardPvForLastestWeekStatistics();
    }
}
